﻿/**
 * 
 * Copyright 2009, 2010 Mike Jamer [email: mikejamer@gmail.com ]
 * 
 * This File is part of Moose IRC
 * 
 * MooseIRC is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * MooseIRC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with MooseIRC.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using moose.irc;

namespace mooseirc.client.windowsforms {

    /// <summary>
    /// Base Communication Channel Form
    /// </summary>
    [CLSCompliant(true)]
    public abstract class CommunicationChannelForm : ChildForm {

        #region [Local Attributes]

        //TODO: Stick reference to input/output controls here


        /// <summary>
        /// Reference to Input Control
        /// </summary>
        protected controls.InputControl input;

        /// <summary>
        /// Reference to Output Control
        /// </summary>
        protected controls.OututputControl output;

        #endregion

        #region [Construction]

        /// <summary>
        /// Initialize Communication Channel Form
        /// </summary>
        /// <param name="parent_form">Parent/Hosting MDI form</param>
        /// <param name="hosted_control">the control this communication form is hosting</param>
        public CommunicationChannelForm(MainForm parent_form, Control hosted_control)
            : base(parent_form, hosted_control) {
            return;
        }

        #endregion

        #region [Public Methods]

        /// <summary>
        /// Write a message to the ourput, from a specific source
        /// </summary>
        /// <param name="source">source of message</param>
        /// <param name="message">actual message</param>
        public void write(IrcUser source, string message) {
            StringBuilder sb = new StringBuilder();
            sb.Append('[');
            sb.Append(DateTime.Now.ToShortTimeString());
            sb.Append(']');
            sb.Append(' ');
            sb.Append('<');
            sb.Append(source.Nickname);
            sb.Append('>');
            sb.Append(' ');
            sb.Append(message);
            output.write(sb.ToString());
            return;
        }

        /// <summary>
        /// echo something to the output
        /// </summary>
        /// <param name="message">message to echo to the output</param>
        public void write(string message) {
            output.write(">" + message);
            return;

        }

        #endregion


    }
}
